#!/usr/bin/python
#coding:utf-8
'''
朴素贝叶斯模型
'''
import numpy as np 
from sklearn.naive_bayes import GaussianNB
import imp 
tool=imp.load_source('tool','./work/src/python/tool/tool.py')
import tool as tl

data_train = np.array([[-1,-1],[-2,-1],[-3,-2],[1,1],[2,1],[3,2]])
labels_train = np.array([1,1,1,2,2,2])

clf=GaussianNB()
clf.fit(data_train,labels_train)  #sample_weight=None 各样本权重数组

print clf.priors
clf.set_params(priors=[0.625,0.375]) #设置每个类标签先验概率
tl.say("每个类先验概率列表："+str(clf.priors))
tl.say("每个类先验概率列表："+str(clf.class_prior_))
tl.say("各类标记的训练样本数："+str(clf.class_count_))
tl.say("各类在各特征上的均值："+str(clf.theta_))
tl.say("各个类标签各特征的方差："+str(clf.theta_))
tl.say("返回priors与其参数值组成的字典："+str(clf.get_params(deep=True)))
tl.say("设置priors参数："+str(clf.set_params(priors=[0.624,0.376])))


data_test=np.array([[-0.8,-1]])
labels_test=np.array([1])
pred=clf.predict(data_test)
tl.say("预测结果"+str(pred))